import 'package:flutter/material.dart';
import 'package:flutter_demo/ui/pages/status/data/share_data.dart';
import 'package:flutter_demo/ui/pages/status/inherited/trans/a_page_widget.dart';
import 'package:flutter_demo/ui/pages/status/inherited/trans/b_page_widget.dart';
import 'package:flutter_demo/ui/pages/status/inherited/trans/share_widget.dart';

//数据传递的功能,功能测试, 此处数值变化无法自动刷新
class InheritedTransTestWidget extends StatefulWidget {
  InheritedTransTestWidget({super.key});
  ShareData shareData = ShareData(nickname: "初始值", level: 11);

  @override
  State<InheritedTransTestWidget> createState() => _InheritedTransTestState();
}

class _InheritedTransTestState extends State<InheritedTransTestWidget> {
  @override
  Widget build(BuildContext context) {
    return ShareWidget(
      shareData: widget.shareData,
      //child: MaterialApp(home: APage()),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          APageWidget(),
          ElevatedButton(
            onPressed: () {
              setState(() {});
            },
            child: Text("更新AB页面"),
          ),
          BPageWidget()
        ],
      ),
    );
  }
}
